import { defHttp } from "/@/utils/http/axios";
import { LectureNoteModel } from "/@/api/model/practicalModel";
import { PageParams, PageResult, PageWithId } from "/@/api/model/pageModel";

enum Api {
  GetLectureNotePage = "/lectureNote/page",
  SaveLectureNote = "/lectureNote/save",
  UpdateLectureNote = "/lectureNote/update",
  RemoveLectureNote = "/lectureNote/remove",
  SetLectureNoteRemark = "/lectureNote/setRemark",
}

export const getLectureNotePageApi = (params: PageParams) =>
  defHttp.get<PageResult<LectureNoteModel>>({ url: Api.GetLectureNotePage, params });

export const getLectureNotePageByIdApi = (params: PageWithId) =>
  defHttp.get<PageResult<LectureNoteModel>>({
    url: `${Api.GetLectureNotePage}/${params.userId}`,
    params,
  });

export const saveLectureNoteApi = (params: LectureNoteModel) =>
  defHttp.post<void>({ url: Api.SaveLectureNote, params });

export const updateLectureNoteApi = (params: LectureNoteModel) =>
  defHttp.put<void>({ url: Api.UpdateLectureNote, params });

export const removeLectureNoteApi = (noteId: number) =>
  defHttp.delete<void>({ url: `${Api.RemoveLectureNote}/${noteId}` });

export const setLectureNoteRemarkApi = (userId: number, noteId: number, content: string) =>
  defHttp.put<void>({
    url: `${Api.SetLectureNoteRemark}/${userId}/${noteId}`,
    params: { content },
  });
